import {RxDialog, Util, RxLayout} from '@lowcode/jpaas-base-lib';

/**
 *
 * 初始化配置
 *  initSetting() {
 *
 *  },
 * 获取配置
 *  getSetting() {
 *       return this.settings;
 *  },
 */

export default {
    components: {
        RxDialog,
        RxLayout
    },
    props:{
        row: {
            type: Object,
            default: {}
        },
        paramMappings: {
            type: Array,
            default: []
        },
        destroy: {
            type: Function
        }
    },
    data() {
        return {
            title: "",
            settings:{},
			defValue:""
        }
    },
    created() {
        this.init();
    },
    methods: {
        init() {
            this.title=this.row.label || this.title;
			this.defValue=this.row.value || this.row.values;
            if(this.initSetting){ //初始化配置方法
                this.initSetting();
            }
            else if(this.row.settings){
                this.settings=this.row.settings;
            }
        },
        handleSubmit() {
            let settings=this.settings;
            //获取配置方法
            if(this.getSetting){
                settings=this.getSetting();
            }
            if(this.row.type=='select' && !this.defValue && this.row.settings.multiSelect){
                this.defValue = [];
            }
            Util.closeWindow(this, "ok",{title:this.title,settings:settings,defValue:this.defValue});
        },
        cancel() {
            Util.closeWindow(this, "cancel");
        }
    },
    watch: {}
}
